package com.example.loop.thymeleafdemo.controller;/*
@author joker
@create 2022-04-30 9:38
SpringMVCdemo01
*/

import com.example.loop.thymeleafdemo.vo.School;
import com.example.loop.thymeleafdemo.vo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ExpressController {
    @RequestMapping("/express-var")
    public String express_varexpres(Model model){
        //添加简单类型的数据
        model.addAttribute("Myname","张三");
        model.addAttribute("Myage",20);

        //添加对象类型的数据
        Student student = new Student();
        student.setId(1001);
        student.setName("理想");
        student.setEmail("lixiang@qq.com");
        student.setAge(22);
        student.sex = "男";

        //创建school对象
        School school = new School();
        school.setName("河南财经政法大学");
        school.setAddress("郑州");

        student.setSchoolscho(school);
        model.addAttribute("student1",student);

        return "var1";
    }
}
